package com.webserver.core;



import com.sun.org.apache.bcel.internal.generic.InstructionConstants;
import com.sun.security.ntlm.Client;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class WebServerApplication {
     private ServerSocket serverSocket;


    public WebServerApplication(){

        try {
            System.out.println("正在启动服务端..");
            serverSocket = new ServerSocket(8088);
            System.out.println("服务端启动完毕..");

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public void start(){

        try {
            while(true) {
                System.out.println("等待客户端连接..");
                Socket socket = serverSocket.accept();
                System.out.println("一个客户端连接了!");

                ClientHandler clientHandler = new ClientHandler(socket);
                Thread thread = new Thread(clientHandler);
                thread.start();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public static void main(String[] args) {
        WebServerApplication webServerApplication=new WebServerApplication();
        webServerApplication.start();
    }
}
